package com.group.mall.service.Impl;

import com.group.mall.domain.POJO.GoodsPro;
import com.group.mall.domain.POJO.ShoppingCart;
import com.group.mall.domain.VO.ShoppingCartVO;
import com.group.mall.mapper.ShoppingCartMapper;
import com.group.mall.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoppingCartServiceImpl implements ShoppingCartService {

    @Autowired
    private ShoppingCartMapper shoppingCartMapper;
    /**
     * 查看购物车
     * @return
     */
    public List<ShoppingCart> showShoppingCart(Integer userId) {
        List<ShoppingCart> List=shoppingCartMapper.list(userId);
        return List;
    }

    /**
     * 根据id删除商品
     * @param id
     */
    public void deleteById(Long id) {
        shoppingCartMapper.deleteById(id);
    }

    @Override
    public List<GoodsPro> showGoodsPro(Integer goodsId) {
        List<GoodsPro> goodsProList=shoppingCartMapper.goodsprolist(goodsId);
        return goodsProList;
    }

    @Override
    public void add(Long id) {
        shoppingCartMapper.add(id);
    }

    @Override
    public void sub(Long id) {
        shoppingCartMapper.sub(id);
    }


    @Override
    public void updatecart(ShoppingCartVO shoppingCartVO){
        shoppingCartMapper.updatecart(shoppingCartVO);
    }
}